package top.cyixlq.chat

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.EditText
import androidx.appcompat.widget.AppCompatEditText

class ChooseActivity : AppCompatActivity() {

    private lateinit var edtNickName: EditText

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_choose)
        edtNickName = findViewById(R.id.edtNickName)
        title = "选择"
    }

    fun choose(v: View) {
        val id = v.id
        val nickName = edtNickName.text.toString().trim()
        if (id == R.id.btnAsServer) {
            MainActivity.start(this, MainActivity.TYPE_SERVER, nickName)
        } else {
            MainActivity.start(this, MainActivity.TYPE_CLIENT, nickName)
        }
    }
}